package com.application.lucky.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;

import com.application.lucky.R;
import com.application.lucky.widget.TitlebarView;
import com.application.mylibrary.base.BaseActivity;

public class ChangeNickActivity extends BaseActivity{
    private static final String TAG = "ChangeNickActivity";

    private TitlebarView mTitleBar;
    private EditText tv_change_name;
    private String nick;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        mTitleBar = (TitlebarView) findViewById(R.id.title_bar);
        mTitleBar.setOnViewClick(new TitlebarView.onViewClick() {
            @Override
            public void leftClick() {
                finishAnim();
            }

            @Override
            public void rightClick() {
                Intent intent = new Intent();
                intent.putExtra("new_nick", tv_change_name.getText().toString());
                setResult(RESULT_OK, intent);
                finishAnim();
            }
        });

        tv_change_name = findViewById(R.id.tv_change_name);
        tv_change_name.setText(nick);
        tv_change_name.setSelection(tv_change_name.length());
    }

    @Override
    public void beforeInit() {
        Intent intent = getIntent();
        nick = intent.getStringExtra("nick");
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_change_nick;
    }

}
